package com.bjwl.web.contrlller.admin;

import com.bjwl.pojo.Partment;
import com.bjwl.pojo.ServiceProject;
import com.bjwl.pojo.vo.BasicQueryVo;
import com.bjwl.service.ServiceProjectService;
import com.bjwl.utils.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Author: dzx
 * @Date:Create：in 2020/5/6 16:31
 * @Description:
 * @Modified By：
 * @Version: 1.0
 */
@Controller
@RequestMapping("/admin")
public class ServiceProjectController {

    @Autowired
    private ServiceProjectService serviceProjectService;

    @RequestMapping("/serviceList")
    public String serviceList(BasicQueryVo vo, Model model){
        PageBean<ServiceProject> pageBean = serviceProjectService.serviceList(vo);
        model.addAttribute("pageBean",pageBean);
        return "main_oa/serve-list";
    }

    @RequestMapping("/addService")
    public @ResponseBody
    boolean addPartment(@RequestBody ServiceProject serviceProject){

        return serviceProjectService.addService(serviceProject);
    }

    /**
     * 修改前回显
     * @param
     * @param model
     * @return
     */
    @RequestMapping("/editStartS")
    public String editStart(Integer id, Model model){
        model.addAttribute("ServiceProject",serviceProjectService.editStart(id));
        return "main_oa/serve-edit";
    }

    /**
     * 修改
     * @param
     * @param
     * @return
     */
    @RequestMapping("/editEndS")
    public @ResponseBody
    boolean editEnd(@RequestBody ServiceProject serviceProject){

        return serviceProjectService.updateServiceProject(serviceProject);
    }

    @RequestMapping("/deleteServiceProject")
    public @ResponseBody
    boolean deletePartment(@RequestBody Integer id){

        return serviceProjectService.deleteServiceProject(id);
    }

}
